﻿
using System.Collections.Generic;
using System.Linq;
using Dexter.DataTransferObject;

namespace Dexter.Domain.Model {
	public static class PageStructureHelper {
		public static IEnumerable<PageStructureDto> ToDtos ( this IEnumerable<PageStructure> s ) {
			return s.Select ( x => x.ToDto ( ) ).ToList ( );
		}

		public static PageStructureDto ToDto ( this PageStructure s ) {
			var r = new PageStructureDto ( );

			r.Id = s.Id;
			r.IsPublished = s.IsPublished;
			r.Slug = s.Slug;
			r.SortOrder = s.SortOrder;
			r.Title = s.Title;

			if (s.Pages != null && s.Pages.Any ( ))
				r.Pages = s.Pages.ToDtos ( );

			return r;
		}
	}
}
